
#!/bin/bash

set -e

# 如果没有build目录，创建该目录
if [! -d `pwd`/build ]; then
    mkdir `pwd`/build
fi
# 确保为空
rm -rf `pwd`/build/*

cd `pwd`/build &&
    cmake .. &&
    make

# 回到根目录 开始安装
cd ..

# 将所有的头文件 copy 到 /usr/include/mymuduo  so库copy到 /usr/lib
if [ ! -d /usr/include/mymuduo ]; then
    mkdir /usr/include/mymuduo
fi

for header in `ls *.h`
do
    cp $header /usr/include/mymuduo
done

cp `pwd`/lib/libmymuduo.so /usr/lib

ldconfig

